#include "remotexmlconfig.h"
#include <QDebug>

RemoteXMLConfig::RemoteXMLConfig(FileDispatcher *dsp)
{
	dispatcher = dsp;
}

bool RemoteXMLConfig::startElement(const QString &namespaceURI, const QString &localName,
								   const QString &qName, const QXmlAttributes &attributes)
{
	if (qName == "file")
	{
		QString conf_name = attributes.value("config_name");
		FTPFile *f = dispatcher->getFileByName(conf_name);                
		if (f)
		{
			Version v;
			f->setFtpPath(attributes.value("ftp_path"));
			v = attributes.value("version");
			f->setNewVersion(v);
                        f->setUpdated(f->getOldVersion()>=f->getNewVersion());
		}
	}
	return true;
}

bool RemoteXMLConfig::endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
{
	return true;
}

bool RemoteXMLConfig::characters(const QString &str)
{
	return true;
}

bool RemoteXMLConfig::fatalError(const QXmlParseException &exception)
{
	return false;
}
